import { BaseEntity, IBFFBaseEntity } from './baseEntity';
import { JsonProperty } from 'json-mapper-object';

export interface IQueryBffPageParams {
    /** 当前页 */
    pageIndex: number;
    /** 每页条数 */
    pageSize: number;
}

export class BffPageEntity {
    /** 当前页 */
    @JsonProperty('pageIndex')
    pageIndex: number = 0;

    /** 每页数量 */
    @JsonProperty('pageSize')
    pageSize: number = 0;

    /** 总条数 */
    @JsonProperty('total')
    total: number = 0;
}

/** BFF列表查询公共实体 */
export class BaseBffPageEntity<P> extends BaseEntity<P>{
    // tslint:disable-next-line: typedef
    constructor(responseData: IBFFBaseEntity<P>, entity?){
        super();
        this.code = responseData.code;
        this.message = responseData.message;
        this.success = responseData.success;
        if (responseData.data) {
            this.result = super.transformRow(responseData.data, entity);
        }
   }
}
